{% extends "base.html" %}
{% block title %}RustDesk WebUI{% endblock %}
{% block legend_name %}All Devices{% endblock %}
{% block content %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div style="padding: 20px; background-color: #F2F2F2;">
  <div class="layui-row layui-col-space15">
  <input type="text" id="globalSearchInput" onkeyup="globalSearch()" placeholder="Search all fields..." style="width: 200px; height: 20px; margin-bottom: 10px;">
    <div class="layui-col-md15">
      <div class="layui-card">
        <div class="layui-card-header">Device Statistics - [Username: {{u.username}}] <a href="/api/add_peer"><i class='fa fa-plus'></i> Add Client</a></div>
        <div class="layui-card-body">
          <table class="layui-table">
            <thead>
              <tr>
                <th>Edit / Delete</th>
                <th>Client ID</th>
                <th>Status</th>
                <th>Version</th>
                <th>Connection Password</th>
                <th>System Username</th>
                <th>Computer Name</th>
                <th>Alias</th>
                <th>Platform</th>
                <th>System</th>
                <th>CPU</th>
                <th>Memory</th>
                <th>Registration Time</th>
                <th>Last Update Time</th>
                <th>IP Address</th>
              </tr>
            </thead>
            <tbody>
              {% for one in single_info %}
              <tr>
                <td><a href="/api/edit_peer?rid={{one.rid}}"><i class='fa fa-edit'></i></a> / <a href="/api/delete_peer?rid={{one.rid}}"><i class='fa fa-trash'></i></a></td>
                <td><a href="rustdesk://{{one.rid}}">{{one.rid}}</a> </td>
                <td>{{one.status}} </td>
                <td>{{one.version}}</td>
                <td>{{one.has_rhash}}</td>
                <td>{{one.username}}</td>
                <td>{{one.hostname}}</td>
                <td>{{one.alias}}</td>
                <td>{{one.platform}}</td>
                <td>{{one.os}}</td>
                <td>{{one.cpu}}</td>
                <td>{{one.memory}}</td>
                <td>{{one.create_time}}</td>
                <td>{{one.update_time}}</td>
                <td>{{one.ip}}</td>
              </tr>
              {% endfor %}
            </tbody>
          </table>
        </div>
      </div>
    </div>

    {% if u.is_admin %}
    <div class="layui-col-md15">
      <div class="layui-card">
        <div class="layui-card-header">All Users</div>
        <div class="layui-card-body">
          <table class="layui-table">
            <thead>
              <tr>
                <th>Client ID</th>
                <th>Owner</th>
                <th>Version</th>
                <th>System Username</th>
                <th>Computer Name</th>
                <th>System</th>
                <th>CPU</th>
                <th>Memory</th>
                <th>Registration Time</th>
                <th>Last Update Time</th>
                <th>Status</th>
                <th>IP Address</th>
              </tr>
            </thead>
            <tbody>
              {% for one in all_info %}
              <tr>
                <td><a href="rustdesk://{{one.rid}}">{{one.rid}}</a> </td>
                {% if one.rust_user|length > 0 %}
                <td>{{one.rust_user}} </td>
                {% else %}
                <td><a href="/api/assign_peer?rid={{one.rid}}"><i class='fa fa-plus'></i> Assign Peer</a></td>
                {% endif %}
                <td>{{one.version}} </td>
                <td>{{one.username}} </td>
                <td>{{one.hostname}} </td>
                <td>{{one.os}} </td>
                <td>{{one.cpu}} </td>
                <td>{{one.memory}} </td>
                <td>{{one.create_time}} </td>
                <td>{{one.update_time}} </td>
                <td>{{one.status}} </td>
                <td>{{one.ip}}</td>
              </tr>
              {% endfor %}
            </tbody>
          </table>
        </div>
      </div>
    </div>
    {% endif %}
  </div>
</div>

{% endblock %}
